package machinery;

import machinery.state.WorkingState;
import machinery.state.MalfunctionState;
import java.util.Map;

/**
 * 拖拉机具体实现
 */
public class Tractor extends Machinery {
    
    public Tractor(String name) {
        super(name, "拖拉机");
    }
    
    @Override
    protected void adjustWorkingParameters(Map<String, Object> environmentData) {
        // 根据土壤湿度调整作业深度
        if (environmentData.containsKey("soilMoisture")) {
            Integer moisture = (Integer) environmentData.get("soilMoisture");
            
            if (moisture > 80) {
                System.out.println(getName() + " 检测到土壤湿度过高(" + moisture + "%)，暂停耕地作业");
                changeState(new MalfunctionState());
            } else if (moisture > 60) {
                System.out.println(getName() + " 检测到土壤湿度适中(" + moisture + "%)，调整耕地深度为浅层");
                changeState(new WorkingState());
            } else {
                System.out.println(getName() + " 检测到土壤湿度适宜(" + moisture + "%)，开始正常耕地作业");
                changeState(new WorkingState());
            }
        }
    }
} 